package org.kotboot.config;

import org.kotboot.filter.AccessFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

/**
 * jisong.sun 2017/9/15 17:32
 */
@SpringBootConfiguration
public class ConfigFilter extends SpringBootServletInitializer {

    private static Logger log = LoggerFactory.getLogger(ConfigFilter.class);

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        AccessFilter accessFilter = new AccessFilter();
        registrationBean.setFilter(accessFilter);
        List<String> urlPatterns = new ArrayList<String>();
        urlPatterns.add("/*");
        registrationBean.setUrlPatterns(urlPatterns);
        return registrationBean;
    }
}
